From e3300fe7e9cc5d6395f744b1ee450bbb09c9410c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 22 Dec 2009 18:35:34 +0000 Subject: [PATCH] Replace process_pending_timers() with process_pending_softirqs(). This ensures that any critical softirqs are handled in a timely manner (e.g., TIME_CALIBRATE_SOFTIRQ) while still avoiding being preempted by the scheduler (by SCHEDULE_SOFTIRQ), which is the reason for avoiding use of do_softirq() directly. Signed-off-by: Keir Fraser --- xen/arch/x86/acpi/cpu_idle.c | 2 +- xen/arch/x86/domain_build.c | 6 +++--- xen/arch/x86/smpboot.c | 4 ++-- xen/common/page_alloc.c | 2 +- xen/common/softirq.c | 16 ++++++++++++++-- xen/common/timer.c | 9 --------- xen/drivers/char/console.c | 2 +- xen/include/xen/softirq.h | 7 +++++++ xen/include/xen/timer.h | 6 ------ 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 35c2723582..45030ba402 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -230,7 +230,7 @@ static void acpi_processor_idle(void) sched_tick_suspend(); /* sched_tick_suspend() can raise TIMER_SOFTIRQ. Process it now. */ - process_pending_timers(); + process_pending_softirqs(); /* * Interrupts must be disabled during bus mastering calculations and diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index c4b4a66921..8f69aab2a9 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -924,7 +924,7 @@ int __init construct_dom0( ((unsigned int *)vphysmap_start)[pfn] = mfn; set_gpfn_from_mfn(mfn, pfn); if (!(pfn & 0xfffff)) - process_pending_timers(); + process_pending_softirqs(); } si->first_p2m_pfn = pfn; si->nr_p2m_frames = d->tot_pages - count; @@ -945,7 +945,7 @@ int __init construct_dom0( ++alloc_epfn; #endif if (!(pfn & 0xfffff)) - process_pending_timers(); + process_pending_softirqs(); } } BUG_ON(pfn != d->tot_pages); @@ -967,7 +967,7 @@ int __init construct_dom0( #undef pfn page++; pfn++; if (!(pfn & 0xfffff)) - process_pending_timers(); + process_pending_softirqs(); } } diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 5bf5461ce8..5220d5173a 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1327,7 +1327,7 @@ void __cpu_die(unsigned int cpu) } mdelay(100); mb(); - process_pending_timers(); + process_pending_softirqs(); if ((++i % 10) == 0) printk(KERN_ERR "CPU %u still not dead...\n", cpu); } @@ -1547,7 +1547,7 @@ int __devinit __cpu_up(unsigned int cpu) cpu_set(cpu, smp_commenced_mask); while (!cpu_isset(cpu, cpu_online_map)) { mb(); - process_pending_timers(); + process_pending_softirqs(); } cpufreq_add_cpu(cpu); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 19a7bd24d1..7139c3d39b 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -893,7 +893,7 @@ void __init scrub_heap_pages(void) for ( mfn = first_valid_mfn; mfn < max_page; mfn++ ) { - process_pending_timers(); + process_pending_softirqs(); pg = mfn_to_page(mfn); diff --git a/xen/common/softirq.c b/xen/common/softirq.c index ecf3379388..7b04f36f2d 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -22,7 +22,7 @@ irq_cpustat_t irq_stat[NR_CPUS]; static softirq_handler softirq_handlers[NR_SOFTIRQS]; -asmlinkage void do_softirq(void) +static void __do_softirq(unsigned long ignore_mask) { unsigned int i, cpu; unsigned long pending; @@ -38,7 +38,7 @@ asmlinkage void do_softirq(void) if ( rcu_pending(cpu) ) rcu_check_callbacks(cpu); - if ( (pending = softirq_pending(cpu)) == 0 ) + if ( (pending = (softirq_pending(cpu) & ~ignore_mask)) == 0 ) break; i = find_first_set_bit(pending); @@ -47,6 +47,18 @@ asmlinkage void do_softirq(void) } } +void process_pending_softirqs(void) +{ + ASSERT(!in_irq() && local_irq_is_enabled()); + /* Do not enter scheduler as it can preempt the calling context. */ + __do_softirq(1ul<lock); } - -void process_pending_timers(void) -{ - unsigned int cpu = smp_processor_id(); - ASSERT(!in_irq() && local_irq_is_enabled()); - if ( test_and_clear_bit(TIMER_SOFTIRQ, &softirq_pending(cpu)) ) - timer_softirq_action(); -} - s_time_t align_timer(s_time_t firsttick, uint64_t period) { if ( !period ) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 97e38ad485..b1ed507f18 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -650,7 +650,7 @@ void __init console_endboot(void) printk("%d... ", 3-i); for ( j = 0; j < 100; j++ ) { - process_pending_timers(); + process_pending_softirqs(); mdelay(10); } } diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index 5d5661fd43..b02c8e2509 100644 --- a/xen/include/xen/softirq.h +++ b/xen/include/xen/softirq.h @@ -33,6 +33,13 @@ void cpumask_raise_softirq(cpumask_t mask, unsigned int nr); void cpu_raise_softirq(unsigned int cpu, unsigned int nr); void raise_softirq(unsigned int nr); +/* + * Process pending softirqs on this CPU. This should be called periodically + * when performing work that prevents softirqs from running in a timely manner. + * Use this instead of do_softirq() when you do not want to be preempted. + */ +void process_pending_softirqs(void); + /* * TASKLETS -- dynamically-allocatable tasks run in softirq context * on at most one CPU at a time. diff --git a/xen/include/xen/timer.h b/xen/include/xen/timer.h index 1994eff00f..f5340d07b7 100644 --- a/xen/include/xen/timer.h +++ b/xen/include/xen/timer.h @@ -102,12 +102,6 @@ extern void migrate_timer(struct timer *timer, unsigned int new_cpu); */ extern void kill_timer(struct timer *timer); -/* - * Process pending timers on this CPU. This should be called periodically - * when performing work that prevents softirqs from running in a timely manner. - */ -extern void process_pending_timers(void); - /* * Bootstrap initialisation. Must be called before any other timer function. */ -- 2.30.2